import request from "../utils/request";


export const workerLogin = (id, password) => {
    const params = new URLSearchParams()
    params.append('workerId', id)
    params.append('password', password)
    return request.put("/worker/login", params)
}

export const findWorkerService = (workerId) => {
    const params = new URLSearchParams()
    params.append("workerId", workerId)
    return request.get("/worker/findByWorkerId", params)
}

//新增
export const addWorkerService = (addWorkerData) => {
    const params = new URLSearchParams()
    for(let key in addWorkerData){
        params.append(key,addWorkerData[key])
    }
    return request.post("/worker/addWorker",params)
}

//查看所有
export const getAllWorkerService = (pageNum,pageSize) => {
    const params={'pageNum':pageNum,'pageSize':pageSize}
    return request.get('/worker/getAllWorker',{params:params})
}

//删除
export const deleteWorkerService = (workerId) => {
    const params = new URLSearchParams()
    params.append("workerId",workerId)
    return request.put('/worker/deleteWorker',params)
}

export const updateWorkerService = (updateWorkerDate) => {
    const params = new URLSearchParams()
    for(let key in updateWorkerDate){
        params.append(key,updateWorkerDate[key])
    }
    return request.put("/worker/updateWorker",params) 
}

//查找所有维修部人员
export const findRepairmanService = () => {
    return request.get('/worker/findRepairman')
}

